package cf.wfen.smsforward;

import android.app.Activity;
import android.content.Context;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.EditText;
import android.widget.TextView;

public class MainActivity extends Activity {

    private final static boolean DEBUG = true;
    private final static String TAG = "main";
    @Override
    protected void onCreate(Bundle savedInstanceState) {

        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        String settingsStr = getSharedPreferences("data", Context.MODE_PRIVATE).getString("settings", "");
        if(DEBUG)Log.d(TAG,"Settings: " + settingsStr);
        EditText editText = (EditText) findViewById(R.id.edit_Settings);
        editText.setText(settingsStr, TextView.BufferType.EDITABLE);
    }

    public void saveSettings(View v)
    {
        EditText settingsText = (EditText) findViewById(R.id.edit_Settings);
        String settingsStr = settingsText.getText().toString();
        SharedPreferences.Editor editor = getSharedPreferences("data", Context.MODE_PRIVATE).edit();
        editor.putString("settings", settingsStr);
        editor.commit();
        if(DEBUG)Log.d(TAG,"Settings: " + settingsStr);
    }

}
